package cn.ilikes.apps.collect.tests.others;

import cn.ilikes.apps.collect.pojos.IlikesUsers;
import cn.ilikes.apps.collect.services.IlikesCollectsServiceException;
import cn.ilikes.apps.collect.services.IlikesUserService;
import cn.ilikes.apps.collect.services.LikesUserServiceException;
import cn.ilikes.apps.collect.tests.BaseTest;

import java.util.concurrent.atomic.AtomicInteger;
public class Test extends BaseTest {

	public void testThread() {
		
		final AtomicInteger size=new AtomicInteger(0);
		long time=System.currentTimeMillis();
		for ( int i = 0; i <50; i++) {
			System.out.println("============================= i  ======"+i);
			Thread xxx = new Thread() {
				@Override
				public void run() {
					
					for(int j=0;j<1;j++){
//						System.out.println("======================= j ============"+j);
				          IlikesUserService iikesUserService = getService(IlikesUserService.SPRING_DEFULT_NAME);
					IlikesUsers likesUsers = new IlikesUsers();
					likesUsers.setRegName("电视应用平台部门"+System.currentTimeMillis()+Math.random());
					likesUsers.setRegPasswd("电视应用平台部门"+System.currentTimeMillis());
					
					try {
						iikesUserService.regUser(likesUsers);
						System.out.println("                                                                                                                                        "+j+"           "+likesUsers.getRegName());
					         
					} catch (Exception e) {
						e.printStackTrace();
//						System.exit(0);
					}
					try {
						Thread.sleep(10);
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					size.addAndGet(1);
					}
				}

			};
			xxx.start();
			try {
				xxx.join();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		time=System.currentTimeMillis()-time;
//		System.out.println("================ >  +" +time);
//		System.out.println("================ >  +" +(size.get()/time));
		
	}

	public void stestA() throws Exception {
		try{
		IlikesUserService iikesUserService = getService(IlikesUserService.SPRING_DEFULT_NAME);

		IlikesUsers likesUsers = new IlikesUsers();
		likesUsers.setRegName("你大爷的000014");
		likesUsers.setRegPasswd("我大爷的333");
		System.out.println("  =========== >1  <=========================================");
		likesUsers=iikesUserService.findIlikesUsersByRegUser("电视应用平台部门13625453211480.5208563040044353");
		System.out.println("  =========== >  2 <=========================================");
//		IlikesUsers likesUser_ = iikesUserService.findIlikesUsersByRegUser("你大爷的000014");
		System.out.println("  =========== >  " + likesUsers.getRegPasswd());
		//		assertEquals("zy2000", likesUsers.getRegPasswd());

		//		IlikesCollectsService likesCollectsService = getService(IlikesCollectsService.SPRING_DEFULT_NAME);
		//		PageEntitys<IlikesMyCollects> pageEntitys = likesCollectsService.findIlikesMyCollectsByfolderId("购房", new Properties(), 1000);
		//		System.out.println(" == > " + pageEntitys.getProperties().size());
		//		for (IlikesMyCollects likesMyfolder : pageEntitys.getEntitys()) {
		//			System.out.println("================  " + likesMyfolder.getUuid());
		//		}
		//		pageEntitys = likesCollectsService.findIlikesMyCollectsByfolderId("购房", pageEntitys.getProperties(), 1000);
		//		System.out.println(" == > " + pageEntitys.getProperties().size());
		//		for (IlikesMyCollects likesMyfolder : pageEntitys.getEntitys()) {
		//			System.out.println("================  " + likesMyfolder.getUuid());
		//		}
		//		pageEntitys = likesCollectsService.findIlikesMyCollectsByfolderId("购房", pageEntitys.getProperties(), 1000);
		//		System.out.println(" == > " + pageEntitys.getProperties().size());
		//		for (IlikesMyCollects likesMyfolder : pageEntitys.getEntitys()) {
		//			System.out.println("================  " + likesMyfolder.getUuid());
		//		}

		//		for)		
		//		IlikesMyfolder likesMyfolder=new IlikesMyfolder();
		//				likesMyfolder.setUuid("1111300001");
		//				likesMyfolder.setName("我的第一个服务器-1");
		//				likesCollectsService.addChildMyfolder("pzzy2000", "11113", likesMyfolder);
		//	}
		//		List<IlikesMyfolder> likesMyfolders= likesCollectsService.findTopIlikesMyfolderByUserId("pzzy2000");

		//		for(IlikesMyfolder  likesMyfolder :likesMyfolders )
		//		{
		//			System.out.println("================  "+likesMyfolder.getIikesUsers().getRegPasswd());
		//		}
		//		for(int i=0;i<10000000;i++)
		//		{
		//		IlikesMyCollects likesMyCollects = new IlikesMyCollects();
		//		likesMyCollects.setUuid("xxxxxxxxxxbbbbbb"+i);
		//		likesMyCollects.setTitle("请把本站地址放进你QQ资料里,以免忘记");
		//		likesMyCollects.setContent("大幅度房贷反垄断劳动法关掉法国队顶顶顶顶短短的非官方购房");
		//		likesCollectsService.addIlikesMyCollects("1111300001", likesMyCollects);
		//		}
		//		result

		}catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		String startKeyId = "";
		boolean result = (startKeyId != null && ((startKeyId instanceof String) ? (!((String) startKeyId).isEmpty()) : true));
		System.out.println("=======  " + result);
	}
}
